import java.util.ArrayList;

public class p002 {
    public static void main(String[] args) {
        hailstone(27);
    }

    static void hailstone(int n) {
        int length = 1;
        ArrayList<Integer> seq = new ArrayList<>();
        seq.add(n);
        while (n > 1) {
            n = n % 2 == 0 ? n / 2 : 3 * n + 1;
            seq.add(n);
            length += 1;
        }
        System.out.println("操作次数为：" + length);
        System.out.println("序列为：" + seq);
    }
}